/*
Run this script on:

        mssql-ct.db.jwan.it,1433.Caronte2013    -  This database will be modified

to synchronize it with:

        kalgan01.cs.jwan.it,1443.Jambo2014_sviluppo

You are recommended to back up your database before running this script

Script created by SQL Compare version 9.0.0 from Red Gate Software Ltd at 10/04/2014 15:00:52

*/
SET NUMERIC_ROUNDABORT OFF
GO
SET ANSI_PADDING, ANSI_WARNINGS, CONCAT_NULL_YIELDS_NULL, ARITHABORT, QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
IF EXISTS (SELECT * FROM tempdb..sysobjects WHERE id=OBJECT_ID('tempdb..#tmpErrors')) DROP TABLE #tmpErrors
GO
CREATE TABLE #tmpErrors (Error int)
GO
SET XACT_ABORT ON
GO
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
GO
BEGIN TRANSACTION
GO
PRINT N'Dropping foreign keys from [dbo].[p_polizze]'
GO
ALTER TABLE [dbo].[p_polizze] DROP
CONSTRAINT [FK_p_polizze_new_p_tipitariffe]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [PK__c_movimenti]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__LORDO__59E6E695]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__NETTO__5ADB0ACE]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__TASSE__5BCF2F07]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__TASSE__5CC35340]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_movi__IVA__5DB77779]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__COMMI__5EAB9BB2]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__N_ADU__5F9FBFEB]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__N_BAM__6093E424]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__N_INF__6188085D]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__LORDO__627C2C96]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__TASSE__637050CF]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__N_VEI__64647508]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__LORDO__65589941]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__TASSE__664CBD7A]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__N_ACC__6740E1B3]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__LORDO__683505EC]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__TASSE__69292A25]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__PENAL__6A1D4E5E]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__SPESE__6B117297]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__SCONT__6C0596D0]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__ASSIC__6CF9BB09]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__DIRIT__6DEDDF42]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__LASTU__6EE2037B]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__CANCE__6FD627B4]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] DROP CONSTRAINT [DF__sync_c_mo__DEFIN__70CA4BED]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[passeg]'
GO
ALTER TABLE [dbo].[passeg] DROP CONSTRAINT [DF__passeg__DOCUMENT__5D60DB10]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Dropping constraints from [dbo].[passeg]'
GO
ALTER TABLE [dbo].[passeg] DROP CONSTRAINT [DF__passeg__TITOLO__5F492382]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Altering [dbo].[p_polizze]'
GO
ALTER TABLE [dbo].[p_polizze] ADD
[PAGA_SPEDIZIONIERE] [bit] NULL CONSTRAINT [DF__p_polizze__PAGA___6E654293] DEFAULT ((0)),
[NOTA_ANNULLAMENTO] [varchar] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[APPUNTI] [varchar] (2000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Altering [dbo].[passeg]'
GO
ALTER TABLE [dbo].[passeg] ALTER COLUMN [NOME] [nvarchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
ALTER TABLE [dbo].[passeg] ALTER COLUMN [COGNOME] [nvarchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
ALTER TABLE [dbo].[passeg] ALTER COLUMN [DOCUMENTO] [nvarchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
ALTER TABLE [dbo].[passeg] ALTER COLUMN [TITOLO] [nvarchar] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
ALTER TABLE [dbo].[passeg] ALTER COLUMN [TELEFONO] [nvarchar] (30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
ALTER TABLE [dbo].[passeg] ALTER COLUMN [LUOGO_NASCITA] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
ALTER TABLE [dbo].[passeg] ALTER COLUMN [NOTE] [nvarchar] (250) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Rebuilding [dbo].[sync_c_movimenti]'
GO
CREATE TABLE [dbo].[tmp_rg_xx_sync_c_movimenti]
(
[SERIAL] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[ORIGINE] [varchar] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[DATA_MOVIMENTO] [datetime] NOT NULL,
[DATA_PARTENZA] [datetime] NOT NULL,
[PRENOTAZIONE] [varchar] (14) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[NUM_SEQUENZA] [int] NULL,
[BIGLIETTO] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[RIFERIMENTO_PRENOTAZIONE] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[CORSA] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[IDLINEA] [varchar] (14) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[NAVE] [varchar] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DESC_NAVE] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[LINEA] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DESC_LINEA] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[LISTINO] [varchar] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DESC_LISTINO] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[MACROREGIONE] [varchar] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DESC_MACROREGIONE] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ITINERARIO] [varchar] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DESC_ITINERARIO] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[AGENZIA] [varchar] (6) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DESC_AGENZIA] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[OPERATORE] [varchar] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DESC_OPERATORE] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[COD_LOCALE] [varchar] (4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[TIPO_BIGLIETTERIA] [varchar] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DESC_TIPO_BIGLIETTERIA] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[VALUTA] [varchar] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[LORDO] [decimal] (18, 2) NOT NULL DEFAULT ((0)),
[NETTO] [decimal] (18, 2) NOT NULL DEFAULT ((0)),
[TASSE] [decimal] (18, 2) NOT NULL DEFAULT ((0)),
[TASSE_IMBARCO] [decimal] (18, 2) NOT NULL DEFAULT ((0)),
[TASSE_SBARCO] [decimal] (18, 2) NOT NULL DEFAULT ((0)),
[IVA] [decimal] (18, 2) NOT NULL DEFAULT ((0)),
[COMMISSIONE] [decimal] (18, 2) NOT NULL DEFAULT ((0)),
[TIPO_CAT_JB] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[N_ADULTI] [int] NOT NULL DEFAULT ((0)),
[N_BAMBINI] [int] NOT NULL DEFAULT ((0)),
[N_INFANT] [int] NOT NULL DEFAULT ((0)),
[LORDO_PAX] [decimal] (18, 2) NOT NULL DEFAULT ((0)),
[TASSE_PAX] [decimal] (18, 2) NOT NULL DEFAULT ((0)),
[CODSCONTO] [char] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DESC_SCONTO] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[N_VEICOLI] [int] NOT NULL DEFAULT ((0)),
[LORDO_VEICOLI] [decimal] (18, 2) NOT NULL DEFAULT ((0)),
[TASSE_VEICOLI] [decimal] (18, 2) NOT NULL DEFAULT ((0)),
[N_ACCESSORI] [int] NOT NULL DEFAULT ((0)),
[LORDO_ACCESSORI] [decimal] (18, 2) NOT NULL DEFAULT ((0)),
[TASSE_ACCESSORI] [decimal] (18, 2) NOT NULL DEFAULT ((0)),
[PENALE] [decimal] (18, 2) NOT NULL DEFAULT ((0)),
[SPESE] [decimal] (18, 2) NOT NULL DEFAULT ((0)),
[SCONTO] [decimal] (18, 2) NOT NULL DEFAULT ((0)),
[RIP_TASSE] [varchar] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[ASSICURAZIONE] [decimal] (18, 2) NOT NULL DEFAULT ((0)),
[DIRITTI] [decimal] (18, 2) NOT NULL DEFAULT ((0)),
[TIPOMOV] [varchar] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[FORMA_PAGAMENTO] [varchar] (5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DESC_FORMA_PAGAMENTO] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[COMPAGNIA] [char] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DESC_COMPAGNIA] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[VETTORE] [char] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DESC_VETTORE] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[POSTAZIONE] [char] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DESC_POSTAZIONE] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[TURNO] [int] NULL,
[RIF_ANNULLAMENTO] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[FATTURA] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[CLIENTE_FATTURA] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[TESSERA_ABB] [varchar] (15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[VOUCHER] [varchar] (10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[GRATUITI] [int] NULL,
[ANDRIT] [char] (1) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[CODIVA_JB] [char] (3) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[BIGLIETTO_MANUALE] [char] (11) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[LASTUPDATE] [datetime] NOT NULL DEFAULT (getdate()),
[CANCELLATO] [bit] NOT NULL DEFAULT ((0)),
[DEFINITIVO] [bit] NOT NULL DEFAULT ((0))
)
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
INSERT INTO [dbo].[tmp_rg_xx_sync_c_movimenti]([SERIAL], [ORIGINE], [DATA_MOVIMENTO], [DATA_PARTENZA], [PRENOTAZIONE], [NUM_SEQUENZA], [BIGLIETTO], [RIFERIMENTO_PRENOTAZIONE], [CORSA], [IDLINEA], [NAVE], [DESC_NAVE], [LINEA], [DESC_LINEA], [LISTINO], [DESC_LISTINO], [MACROREGIONE], [DESC_MACROREGIONE], [ITINERARIO], [DESC_ITINERARIO], [AGENZIA], [DESC_AGENZIA], [OPERATORE], [DESC_OPERATORE], [COD_LOCALE], [TIPO_BIGLIETTERIA], [DESC_TIPO_BIGLIETTERIA], [VALUTA], [LORDO], [NETTO], [TASSE], [TASSE_IMBARCO], [IVA], [COMMISSIONE], [TIPO_CAT_JB], [N_ADULTI], [N_BAMBINI], [N_INFANT], [LORDO_PAX], [TASSE_PAX], [CODSCONTO], [DESC_SCONTO], [N_VEICOLI], [LORDO_VEICOLI], [TASSE_VEICOLI], [N_ACCESSORI], [LORDO_ACCESSORI], [TASSE_ACCESSORI], [PENALE], [SPESE], [SCONTO], [RIP_TASSE], [ASSICURAZIONE], [DIRITTI], [TIPOMOV], [FORMA_PAGAMENTO], [DESC_FORMA_PAGAMENTO], [COMPAGNIA], [DESC_COMPAGNIA], [VETTORE], [DESC_VETTORE], [POSTAZIONE], [DESC_POSTAZIONE], [TURNO], [RIF_ANNULLAMENTO], [FATTURA], [CLIENTE_FATTURA], [TESSERA_ABB], [VOUCHER], [GRATUITI], [ANDRIT], [CODIVA_JB], [BIGLIETTO_MANUALE], [LASTUPDATE], [CANCELLATO], [DEFINITIVO]) SELECT [SERIAL], [ORIGINE], [DATA_MOVIMENTO], [DATA_PARTENZA], [PRENOTAZIONE], [NUM_SEQUENZA], [BIGLIETTO], [RIFERIMENTO_PRENOTAZIONE], [CORSA], [IDLINEA], [NAVE], [DESC_NAVE], [LINEA], [DESC_LINEA], [LISTINO], [DESC_LISTINO], [MACROREGIONE], [DESC_MACROREGIONE], [ITINERARIO], [DESC_ITINERARIO], [AGENZIA], [DESC_AGENZIA], [OPERATORE], [DESC_OPERATORE], [COD_LOCALE], [TIPO_BIGLIETTERIA], [DESC_TIPO_BIGLIETTERIA], [VALUTA], [LORDO], [NETTO], [TASSE], [TASSE_IMBARCO], [IVA], [COMMISSIONE], [TIPO_CAT_JB], [N_ADULTI], [N_BAMBINI], [N_INFANT], [LORDO_PAX], [TASSE_PAX], [CODSCONTO], [DESC_SCONTO], [N_VEICOLI], [LORDO_VEICOLI], [TASSE_VEICOLI], [N_ACCESSORI], [LORDO_ACCESSORI], [TASSE_ACCESSORI], [PENALE], [SPESE], [SCONTO], [RIP_TASSE], [ASSICURAZIONE], [DIRITTI], [TIPOMOV], [FORMA_PAGAMENTO], [DESC_FORMA_PAGAMENTO], [COMPAGNIA], [DESC_COMPAGNIA], [VETTORE], [DESC_VETTORE], [POSTAZIONE], [DESC_POSTAZIONE], [TURNO], [RIF_ANNULLAMENTO], [FATTURA], [CLIENTE_FATTURA], [TESSERA_ABB], [VOUCHER], [GRATUITI], [ANDRIT], [CODIVA_JB], [BIGLIETTO_MANUALE], [LASTUPDATE], [CANCELLATO], [DEFINITIVO] FROM [dbo].[sync_c_movimenti]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
DROP TABLE [dbo].[sync_c_movimenti]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
EXEC sp_rename N'[dbo].[tmp_rg_xx_sync_c_movimenti]', N'sync_c_movimenti'
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Creating primary key [PK__c_movimenti] on [dbo].[sync_c_movimenti]'
GO
ALTER TABLE [dbo].[sync_c_movimenti] ADD CONSTRAINT [PK__c_movimenti] PRIMARY KEY CLUSTERED  ([SERIAL], [ORIGINE])
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Adding constraints to [dbo].[passeg]'
GO
ALTER TABLE [dbo].[passeg] ADD CONSTRAINT [DF__passeg__DOCUMENT__5D60DB10] DEFAULT (' ') FOR [DOCUMENTO]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
ALTER TABLE [dbo].[passeg] ADD CONSTRAINT [DF__passeg__TITOLO__5F492382] DEFAULT (' ') FOR [TITOLO]
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
PRINT N'Adding foreign keys to [dbo].[p_polizze]'
GO
ALTER TABLE [dbo].[p_polizze] ADD
CONSTRAINT [FK_p_polizze_new_p_tipitariffe] FOREIGN KEY ([CODTARIFFA]) REFERENCES [dbo].[p_tipitariffe] ([CODTARIFFA])
GO
IF @@ERROR<>0 AND @@TRANCOUNT>0 ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT=0 BEGIN INSERT INTO #tmpErrors (Error) SELECT 1 BEGIN TRANSACTION END
GO
IF EXISTS (SELECT * FROM #tmpErrors) ROLLBACK TRANSACTION
GO
IF @@TRANCOUNT>0 BEGIN
PRINT 'The database update succeeded'
COMMIT TRANSACTION
END
ELSE PRINT 'The database update failed'
GO
DROP TABLE #tmpErrors
GO
